package org.studiox.graph.common.exception;

public class GraphException extends Exception {

  private GraphExceptionCode exceptionCode;

  public GraphException(GraphExceptionCode exceptionCode) {
    super();
    this.setExceptionCode(exceptionCode);
  }

  public GraphException(String message, GraphExceptionCode exceptionCode) {
    super(exceptionCode.getExceptionMsg(message));
    this.setExceptionCode(exceptionCode);
  }

  public GraphException(Throwable cause, GraphExceptionCode exceptionCode) {
    super(cause);
    this.setExceptionCode(exceptionCode);
  }

  public GraphException(String message, Throwable cause, GraphExceptionCode exceptionCode) {
    super(exceptionCode.getExceptionMsg(message), cause);
    this.setExceptionCode(exceptionCode);
  }

  public GraphException(
      String message,
      Throwable cause,
      boolean enableSuppression,
      boolean writableStackTrace,
      GraphExceptionCode exceptionCode) {
    super(exceptionCode.getExceptionMsg(message), cause, enableSuppression, writableStackTrace);
    this.setExceptionCode(exceptionCode);
  }

  public GraphExceptionCode getExceptionCode() {
    return exceptionCode;
  }

  public void setExceptionCode(GraphExceptionCode exceptionCode) {
    this.exceptionCode = exceptionCode;
  }

  @Override
  public String toString() {
    final StringBuffer stringBuffer = new StringBuffer("GraphException{");
    stringBuffer.append("exceptionCode=").append(exceptionCode);
    stringBuffer.append('}');
    return stringBuffer.toString();
  }
}
